---
category: DOM
created: '2020-04-19'
title: Check if an element is a descendant of another
updated: '2021-10-13'
---

**JavaScript version**

```js isDescendant.js
const isDescendant = (child, parent) => parent.contains(child);
```

**TypeScript version**

```ts isDescendant.ts
const isDescendant = (child: Node, parent: Node): boolean => parent.contains(child);
```
